/*
 * Copyright 2013-2015 the original author or authors.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.xdtech.hotel.init;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.thoughtworks.xstream.XStream;
import com.xdtech.common.service.impl.BaseService;
import com.xdtech.common.utils.EmptyUtil;
import com.xdtech.core.init.SysInitOperation;
import com.xdtech.core.model.BaseModel;
import com.xdtech.hotel.model.CardType;
import com.xdtech.hotel.model.Device;
import com.xdtech.hotel.model.DeviceLink;
import com.xdtech.hotel.monitor.RtEventHandler;
import com.xdtech.hotel.protocol.ProtocolManager;
import com.xdtech.hotel.protocol.manager.RoomMonitor;
import com.xdtech.hotel.protocol.vo.Ac;
import com.xdtech.hotel.protocol.vo.Dimmer;
import com.xdtech.hotel.protocol.vo.Music;
import com.xdtech.hotel.protocol.vo.Node;
import com.xdtech.hotel.protocol.vo.Tv;
import com.xdtech.hotel.util.HotelConstants;
import com.xdtech.sys.model.CodeValue;
import com.xdtech.sys.model.DictionaryCode;
import com.xdtech.sys.model.MenuFunction;
import com.xdtech.sys.model.Operation;
import com.xdtech.sys.model.Params;
/**
 * 
 * @author max.zheng
 * @create 2015-4-4下午11:57:24
 * @since 1.0
 * @see
 */
public class HotelInit implements SysInitOperation{
	Log log = LogFactory.getLog(HotelInit.class);
//	private static BaseService baseService;
	/**
	 * @description
	 * @author max.zheng
	 * @create 2015-4-4下午11:58:10
	 * @modified by
	 * @param baseService
	 */
	@Override
	public void initingToDb(BaseService<BaseModel> baseService) {
		List params = (List) baseService.findByHql("from Params where code=? and codeValue=?", "HotelInit","true");
		log.info("Hotel模块数据库初始化......");
		if (EmptyUtil.isEmpty(params)) {
			initData(baseService);
			Params p = new Params("HotelInit", "true", "酒店模块数据库初始化标记");
			baseService.save(p);
			log.info("Hotel模块数据库初始化......结束");
		}else {
			log.info("Hotel模块数据库已经初始化......完毕");
		}
	}

	/**
	 * 
	 * @author max.zheng
	 * @create 2015-2-15下午10:29:11
	 * @modified by
	 * @param m11
	 */
	private static void createButtonOperations(String nameCN, String operationCode,
			MenuFunction menuFunction,BaseService baseService) {
		Operation operation = new Operation(nameCN, operationCode, menuFunction);
		baseService.save(operation); 
		
	}
	/**
	 * 
	 * @author max.zheng
	 * @create 2015-5-31下午11:03:06
	 * @modified by
	 * @param baseService
	 */
	private void initData(BaseService<BaseModel> baseService) {
		MenuFunction m1 = new MenuFunction();
		m1.setIconName("icon-save");
		m1.setNameCN("酒店管理");
		m1.setOperationCode("hotel-manage");
		m1.setPageUrl(null);
		baseService.save(m1);
		
		
		
		MenuFunction m11 = new MenuFunction();
		m11.setIconName("icon-save");
		m11.setNameCN("酒店信息");
		m11.setOperationCode("hotel-info-manage");
		m11.setPageUrl("hotelInfo.do?hotelInfo");
		m11.setParent(m1);
		baseService.save(m11);
		createButtonOperations("确定保存","hotel:hotelinfo:edit",m11,baseService);
		
		MenuFunction m12 = new MenuFunction();
		m12.setIconName("icon-save");
		m12.setNameCN("设备管理");
		m12.setOperationCode("device-manage");
		m12.setPageUrl("device.do?device");
		m12.setParent(m1);
		baseService.save(m12);
		createButtonOperations("新增","hotel:device:add",m12,baseService);
		createButtonOperations("删除","hotel:device:delete",m12,baseService);
		createButtonOperations("编辑","hotel:device:edit",m12,baseService);
		createButtonOperations("同步时间","hotel:device:syncTime",m12,baseService);
		createButtonOperations("刷新","hotel:device:refresh",m12,baseService);
		
		MenuFunction m13 = new MenuFunction();
		m13.setIconName("icon-save");
		m13.setNameCN("设备监控");
		m13.setOperationCode("device-monitor");
		m13.setPageUrl("device.do?monitoring");
		m13.setParent(m1);
		baseService.save(m13);
		
		
		
		MenuFunction m14 = new MenuFunction();
		m14.setIconName("icon-save");
		m14.setNameCN("客房管理");
		m14.setOperationCode("room-manage");
		m14.setPageUrl("room.do?room");
		m14.setParent(m1);
		baseService.save(m14);
		
		createButtonOperations("新增","hotel:room:add",m14,baseService);
		createButtonOperations("删除","hotel:room:delete",m14,baseService);
		createButtonOperations("编辑","hotel:room:edit",m14,baseService);
		createButtonOperations("刷新","hotel:room:refresh",m14,baseService);
		createButtonOperations("入住登记","hotel:room:live",m14,baseService);
		createButtonOperations("离开登记","hotel:room:leave",m14,baseService);
		createButtonOperations("下载模版","hotel:room:downLoadTemplate",m14,baseService);
		createButtonOperations("导入","hotel:room:importTemplate",m14,baseService);
		
		
		MenuFunction m15 = new MenuFunction();
		m15.setIconName("icon-save");
		m15.setNameCN("卡管理");
		m15.setOperationCode("card-manage");
		m15.setPageUrl("card.do?card");
		m15.setParent(m1);
		baseService.save(m15);
		createButtonOperations("新增","hotel:card:add",m15,baseService);
		createButtonOperations("删除","hotel:card:delete",m15,baseService);
		createButtonOperations("编辑","hotel:card:edit",m15,baseService);
		createButtonOperations("刷新","hotel:card:refresh",m15,baseService);
		
		MenuFunction m16 = new MenuFunction();
		m16.setIconName("icon-save");
		m16.setNameCN("宾客管理");
		m16.setOperationCode("customer-manage");
		m16.setPageUrl("customer.do?customer");
		m16.setParent(m1);
		baseService.save(m16);
		createButtonOperations("删除","hotel:customer:delete",m16,baseService);
		createButtonOperations("刷新","hotel:customer:refresh",m16,baseService);
		
		MenuFunction m17 = new MenuFunction();
		m17.setIconName("icon-save");
		m17.setNameCN("设备事件记录");
		m17.setOperationCode("device-event");
		m17.setPageUrl("deviceEvent.do?deviceEvent");
		m17.setParent(m1);
		baseService.save(m17);
		
		MenuFunction m2 = new MenuFunction();
		m2.setIconName("icon-save");
		m2.setNameCN("配置相关");
		m2.setOperationCode("hotel-config-manage");
		m2.setPageUrl(null);;
		baseService.save(m2);
		

//		MenuFunction m21 = new MenuFunction();
//		m21.setIconName("icon-save");
//		m21.setNameCN("元件配置");
//		m21.setOperationCode("device-link-manage");
//		m21.setPageUrl("deviceLink.do?deviceLink");
//		m21.setParent(m2);
//		baseService.save(m21);
		
		MenuFunction m22 = new MenuFunction();
		m22.setIconName("icon-save");
		m22.setNameCN("客房配置");
		m22.setOperationCode("room-config-manage");
		m22.setPageUrl("roomConfig.do?roomConfig");
		m22.setParent(m2);
		baseService.save(m22);
		createButtonOperations("新增","hotel:roomConfig:add",m22,baseService);
		createButtonOperations("删除","hotel:roomConfig:delete",m22,baseService);
		createButtonOperations("编辑","hotel:roomConfig:edit",m22,baseService);
		createButtonOperations("刷新","hotel:roomConfig:refresh",m22,baseService);
		createButtonOperations("新增设备","hotel:deviceLink:add",m22,baseService);
		createButtonOperations("删除设备","hotel:deviceLink:delete",m22,baseService);
		createButtonOperations("编辑设备","hotel:deviceLink:edit",m22,baseService);
		createButtonOperations("刷新设备","hotel:deviceLink:refresh",m22,baseService);
		
		MenuFunction m23 = new MenuFunction();
		m23.setIconName("icon-save");
		m23.setNameCN("卡识别类型");
		m23.setOperationCode("card-type-manage");
		m23.setPageUrl("cardType.do?cardType");
		m23.setParent(m2);
		baseService.save(m23);
		createButtonOperations("新增","hotel:cardType:add",m23,baseService);
		createButtonOperations("删除","hotel:cardType:delete",m23,baseService);
		createButtonOperations("编辑","hotel:cardType:edit",m23,baseService);
		createButtonOperations("刷新","hotel:cardType:refresh",m23,baseService);
		
		MenuFunction m24 = new MenuFunction();
		m24.setIconName("icon-save");
		m24.setNameCN("联动配置");
		m24.setOperationCode("linkage-config-manage");
		m24.setPageUrl("linkageConfig.do?linkageConfig");
		m24.setParent(m2);
		baseService.save(m24);
		
		createButtonOperations("新增","hotel:linkageConfig:add",m24,baseService);
		createButtonOperations("删除","hotel:linkageConfig:delete",m24,baseService);
		createButtonOperations("编辑","hotel:linkageConfig:edit",m24,baseService);
		createButtonOperations("刷新","hotel:linkageConfig:refresh",m24,baseService);
		createButtonOperations("新增动作","hotel:deviceOperation:add",m24,baseService);
		createButtonOperations("删除动作","hotel:deviceOperation:delete",m24,baseService);
		createButtonOperations("编辑动作","hotel:deviceOperation:edit",m24,baseService);
		createButtonOperations("刷新动作","hotel:deviceOperation:refresh",m24,baseService);
		
		MenuFunction m25 = new MenuFunction();
		m25.setIconName("icon-save");
		m25.setNameCN("通信指令");
		m25.setOperationCode("protocol-cmd-manage");
		m25.setPageUrl("protocolCmd.do?protocolCmd");
		m25.setParent(m2);
		baseService.save(m25);
		
		MenuFunction m29 = new MenuFunction();
		m29.setIconName("icon-save");
		m29.setNameCN("通信测试");
		m29.setOperationCode("room-config-manage");
		m29.setPageUrl("devOperation.do?operationTest");
		m29.setParent(m2);
		baseService.save(m29);
		
		MenuFunction m30 = new MenuFunction();
		m30.setIconName("icon-save");
		m30.setNameCN("通信自定义");
		m30.setOperationCode("room-config-manage");
		m30.setPageUrl("testData.do?testData");
		m30.setParent(m2);
		baseService.save(m30);
		//初始化元件信息
		DeviceLink deviceLink = new DeviceLink("音乐背景", "music");
		deviceLink.setComponent(new XStream().toXML(new Music("1", "1", "on", "20", "0", "0", "next")));
		baseService.save(deviceLink);
//		baseService.save(new DeviceLinkOption("id", "0","元件操作标记", deviceLink));
//		baseService.save(new DeviceLinkOption("cmd", "w","w写数据,r读数据", deviceLink));
//		baseService.save(new DeviceLinkOption("power", "off","on开, off关", deviceLink));
//		baseService.save(new DeviceLinkOption("volume", "50","声音大小", deviceLink));
		
		deviceLink = new DeviceLink("空调", "ac");
		deviceLink.setComponent(new XStream().toXML(new Ac("2", "2", "off", "auto", "low", "20")));
		baseService.save(deviceLink);

		deviceLink = new DeviceLink("电视", "tv");
		deviceLink.setComponent(new XStream().toXML(new Tv("3", "3", "off", "30", "0", "0", "next")));
		baseService.save(deviceLink);

		deviceLink = new DeviceLink("调光", "dimmer");
		deviceLink.setComponent(new XStream().toXML(new Dimmer("4", "4", "off", "0", "0", "0")));
		baseService.save(deviceLink);

		deviceLink = new DeviceLink("排气扇", "node");
		deviceLink.setComponent(new XStream().toXML(new Node(HotelConstants.NODE_EXHAUST, "5", "5", "off", "0", "0")));
		baseService.save(deviceLink);
		deviceLink = new DeviceLink("射灯", "node");
		deviceLink.setComponent(new XStream().toXML(new Node(HotelConstants.NODE_LIGHTS, "6", "6", "off", "0", "0")));
		baseService.save(deviceLink);
		
		deviceLink = new DeviceLink("镜前灯", "node");
		deviceLink.setComponent(new XStream().toXML(new Node(HotelConstants.NODE_LIGHTS, "7", "7", "off", "0", "0")));
		baseService.save(deviceLink);
		
		deviceLink = new DeviceLink("灯带", "node");
		deviceLink.setComponent(new XStream().toXML(new Node(HotelConstants.NODE_LIGHTS, "8", "8", "off", "0", "0")));
		baseService.save(deviceLink);
		
		deviceLink = new DeviceLink("卫生间灯带", "node");
		deviceLink.setComponent(new XStream().toXML(new Node(HotelConstants.NODE_LIGHTS, "9", "9", "off", "0", "0")));
		baseService.save(deviceLink);
		
		deviceLink = new DeviceLink("卫生间射灯", "node");
		deviceLink.setComponent(new XStream().toXML(new Node(HotelConstants.NODE_LIGHTS, "10", "10", "off", "0", "0")));
		baseService.save(deviceLink);
		
		deviceLink = new DeviceLink("卫生间灯", "node");
		deviceLink.setComponent(new XStream().toXML(new Node(HotelConstants.NODE_LIGHTS, "11", "11", "off", "0", "0")));
		baseService.save(deviceLink);
		
		deviceLink = new DeviceLink("吊灯", "node");
		deviceLink.setComponent(new XStream().toXML(new Node(HotelConstants.NODE_LIGHTS, "12", "12", "off", "0", "0")));
		baseService.save(deviceLink);
		
		deviceLink = new DeviceLink("电视2", "tv");
		deviceLink.setComponent(new XStream().toXML(new Tv("13", "13", "off", "30", "0", "0", "next")));
		baseService.save(deviceLink);
		//初始化一个设备
		Device device = new Device("123456789", "192.168.0.1", "RCU-101", "9000");
		baseService.save(device);
		//初始化配置模板
		//0-管理，1-顾客，2-保洁，3-维修
		CardType cardType = new CardType("0","管理卡");
		baseService.save(cardType);
		cardType = new CardType("1","顾客卡");
		baseService.save(cardType);
		cardType = new CardType("2","保洁卡");
		baseService.save(cardType);
		cardType = new CardType("3","维修卡");
		baseService.save(cardType);
		//数据字典
		//房间元件类型
 		DictionaryCode dictionaryCode = new DictionaryCode("COMPONENT_TYPE","元件类型");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue(HotelConstants.DEV_AC_CONTROL,"空调",1,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.DEV_MUSIC_CONTROL,"音乐",2,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.DEV_TV_CONTROL,"电视",3,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.DEV_DIMMER_CONTROL,"调光",4,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.DEV_NODE_CONTROL,"节点",5,dictionaryCode));
		
		dictionaryCode = new DictionaryCode("NODE_TYPE","节点类型");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue(HotelConstants.NODE_LIGHTS,"灯光",1,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.NODE_BLIND,"窗帘",2,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.NODE_DOORPLATE,"门牌",3,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.NODE_PANEL,"面板",4,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.NODE_EXHAUST,"排气扇",4,dictionaryCode));
		
		dictionaryCode = new DictionaryCode(HotelConstants.NODE_LIGHTS+"_STATUS","灯光状态");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("on","开",1,dictionaryCode));
		baseService.save(new CodeValue("off","关",2,dictionaryCode));
		baseService.save(new CodeValue("blink","闪烁",3,dictionaryCode));
		
		dictionaryCode = new DictionaryCode(HotelConstants.NODE_BLIND+"_STATUS","窗帘状态");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("on","开",1,dictionaryCode));
		baseService.save(new CodeValue("off","关",2,dictionaryCode));
		
		dictionaryCode = new DictionaryCode(HotelConstants.NODE_DOORPLATE+"_STATUS","门牌状态");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("on","开",1,dictionaryCode));
		
		dictionaryCode = new DictionaryCode(HotelConstants.NODE_PANEL+"_STATUS","面板状态");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("on","开",1,dictionaryCode));
		baseService.save(new CodeValue("off","关",2,dictionaryCode));
		
		dictionaryCode = new DictionaryCode(HotelConstants.NODE_EXHAUST+"_STATUS","排气扇状态");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("on","开",1,dictionaryCode));
		baseService.save(new CodeValue("off","关",2,dictionaryCode));
		
		dictionaryCode = new DictionaryCode("ROOM_TYPE","房间类型");
		baseService.save(dictionaryCode);
		
		baseService.save(new CodeValue(HotelConstants.ROOM_SIMPLE_DOUBLE_TYPE,"经济双人房",1,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.ROOM_SIMPLE_SINGLE_TYPE,"经济单人房",2,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.ROOM_PRESIDENT_TYPE,"总统房",3,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.ROOM_VIP_TYPE,"贵宾房",4,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.ROOM_STANDARD_DOUBLE_TYPE,"标准双人房",5,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.ROOM_STANDARD_SINGLE_TYPE,"标准单人房",6,dictionaryCode));


		dictionaryCode = new DictionaryCode("SERVICE_AREA","服务区域");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("COMMON-AREA","普通区",1,dictionaryCode));
		baseService.save(new CodeValue("VIP-AREA","贵宾区",2,dictionaryCode));
		
		dictionaryCode = new DictionaryCode("ROOM_STATUS","房间状态");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("1","脏空",1,dictionaryCode));
		baseService.save(new CodeValue("2","入住",2,dictionaryCode));
		baseService.save(new CodeValue("3","故障",3,dictionaryCode));
		baseService.save(new CodeValue("4","干净",4,dictionaryCode));
		baseService.save(new CodeValue("5","预退",5,dictionaryCode));
		baseService.save(new CodeValue("6","预约",6,dictionaryCode));
		
		dictionaryCode = new DictionaryCode("ROOM_OPERATION_STATUS","房间操作状态");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("0","无 ",1,dictionaryCode));
		baseService.save(new CodeValue("1","请求清扫 ",2,dictionaryCode));
		baseService.save(new CodeValue("2","取消清扫 ",3,dictionaryCode));
		baseService.save(new CodeValue("3","请求退房",4,dictionaryCode));
		baseService.save(new CodeValue("4","取消退房",5,dictionaryCode));
		baseService.save(new CodeValue("5","请求送餐",6,dictionaryCode));
		baseService.save(new CodeValue("6","取消送餐 ",7,dictionaryCode));
		baseService.save(new CodeValue("7","请求洗衣 ",8,dictionaryCode));
		baseService.save(new CodeValue("8","取消洗衣 ",9,dictionaryCode));
		baseService.save(new CodeValue("9","请求搬运 ",10,dictionaryCode));
		baseService.save(new CodeValue("10","取消搬运",11,dictionaryCode));
		baseService.save(new CodeValue("11","请求勿扰",12,dictionaryCode));
		baseService.save(new CodeValue("12","取消勿扰",13,dictionaryCode));
		baseService.save(new CodeValue("13","顾客不满 ",14,dictionaryCode));
		baseService.save(new CodeValue("14","取消不满",15,dictionaryCode));
		baseService.save(new CodeValue("15","顾客报警",16,dictionaryCode));
		baseService.save(new CodeValue("16","取消报警 ",17,dictionaryCode));
		
		baseService.save(new CodeValue("27","顾客插卡",28,dictionaryCode));
		baseService.save(new CodeValue("28","顾客拔卡",29,dictionaryCode));
		baseService.save(new CodeValue("29","维修人插卡",30,dictionaryCode));
		baseService.save(new CodeValue("30","维修人拔卡",31,dictionaryCode));
		baseService.save(new CodeValue("31","清洁人插卡",32,dictionaryCode));
		baseService.save(new CodeValue("32","清洁人拔卡",33,dictionaryCode));
		
		dictionaryCode = new DictionaryCode("CUSTOMER_STATUS","顾客状态");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("1","入住",1,dictionaryCode));
		baseService.save(new CodeValue("2","离开",2,dictionaryCode));
		
		dictionaryCode = new DictionaryCode("AC_MODE","空调模式");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("auto","自动",1,dictionaryCode));
		baseService.save(new CodeValue("cool","制冷",2,dictionaryCode));
		baseService.save(new CodeValue("hot","制热",3,dictionaryCode));
		baseService.save(new CodeValue("fan","送风",4,dictionaryCode));
		
		dictionaryCode = new DictionaryCode("AC_FAN","空调送风模式");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("auto","自动",1,dictionaryCode));
		baseService.save(new CodeValue("low","低速",2,dictionaryCode));
		baseService.save(new CodeValue("mid","中速",3,dictionaryCode));
		baseService.save(new CodeValue("high","高速",4,dictionaryCode));
		
		dictionaryCode = new DictionaryCode("COM_POWER","开关");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("on","开",1,dictionaryCode));
		baseService.save(new CodeValue("off","关",2,dictionaryCode));
		
		dictionaryCode = new DictionaryCode("COM_WR","读或写动作");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("w","写",1,dictionaryCode));
		baseService.save(new CodeValue("r","读",2,dictionaryCode));
		
		dictionaryCode = new DictionaryCode("OPERATION_TYPE","联动动作类型");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("1","动作模式",1,dictionaryCode));
		baseService.save(new CodeValue("2","场景模式",2,dictionaryCode));
		
		dictionaryCode = new DictionaryCode("RCU_CONTROL_TYPE","控制类型");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue(HotelConstants.DEV_NODE_CONTROL,"节点控制",1,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.DEV_DIMMER_CONTROL,"调光控制",2,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.DEV_AC_CONTROL,"空调控制",3,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.DEV_TV_CONTROL,"电视控制",4,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.DEV_MUSIC_CONTROL,"音乐控制",5,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.DEV_SCENE_CONTROL,"场景控制",6,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.DEV_TIME_CONTROL,"设置时间",7,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.DEV_CARD_CONTROL,"卡片设置",8,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.DEV_POST_FAULT_FLAG,"故障反馈",9,dictionaryCode));
		baseService.save(new CodeValue(HotelConstants.DEV_POST_ROOM_FLAG,"房态变更",10,dictionaryCode));
		
		dictionaryCode = new DictionaryCode("CARD_TYPE","卡类型");
		baseService.save(dictionaryCode);
		//0-管理，1-顾客，2-保洁，3-维修； 
		baseService.save(new CodeValue("0","管理卡",1,dictionaryCode));
		baseService.save(new CodeValue("1","顾客卡",2,dictionaryCode));
		baseService.save(new CodeValue("2","保洁卡",3,dictionaryCode));
		baseService.save(new CodeValue("3","维修卡",4,dictionaryCode));
		
		dictionaryCode = new DictionaryCode("PROGRAM_ITEM","节目操作");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("previous","节目-",1,dictionaryCode));
		baseService.save(new CodeValue("next","节目+",2,dictionaryCode));
		
		dictionaryCode = new DictionaryCode("DIMMER_STATUS","灯光状态");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("on","开",1,dictionaryCode));
		baseService.save(new CodeValue("off","关",2,dictionaryCode));
		baseService.save(new CodeValue("blink","闪烁",3,dictionaryCode));
		
		dictionaryCode = new DictionaryCode("POWER_STATUS","开关状态");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("on","开",1,dictionaryCode));
		baseService.save(new CodeValue("off","关",2,dictionaryCode));
		
		dictionaryCode = new DictionaryCode("ROOM_SCENE","场景选择");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("1","节能模式",1,dictionaryCode));
		baseService.save(new CodeValue("2","睡眠模式",2,dictionaryCode));
		baseService.save(new CodeValue("3","外出模式",3,dictionaryCode));
		
		dictionaryCode = new DictionaryCode("ROOM_FLOOR","楼层");
		baseService.save(dictionaryCode);
		baseService.save(new CodeValue("1","1楼",1,dictionaryCode));
		baseService.save(new CodeValue("2","2楼",2,dictionaryCode));
		baseService.save(new CodeValue("3","3楼",3,dictionaryCode));
	}

	/**
	 * @description
	 * @author max.zheng
	 * @create 2015-4-4下午11:58:10
	 * @modified by
	 * @param baseService
	 */
	@Override
	public void initingToCache(BaseService<BaseModel> baseService) {
		log.info("初始化酒店缓存数据......");
		//初始化内存房间监控数据
		RoomMonitor.initMonitorDatas(baseService);
		RtEventHandler.runingHandlerRtEventThread();
		//初始化通信监控
		ProtocolManager.initingToCache(baseService);
		log.info("初始化酒店缓存数据结束......");
	}

	/**
	 * @description
	 * @author max.zheng
	 * @create 2015-4-4下午11:58:10
	 * @modified by
	 * @return
	 */
	@Override
	public int getInitOrder() {
		return 22;
	}

	/* (非 Javadoc)
	 * initingToWebApplication
	 * <p>对override方法的补充说明，若不需要则删除此行</p>
	 * 
	 * @param baseService
	 * @see com.xdtech.core.init.SysInitOperation#initingToWebApplication(com.xdtech.common.service.impl.BaseService)
	 */
	@Override
	public void initingToWebApplication(BaseService<BaseModel> baseService)
	{
		// TODO Auto-generated method stub
		
	}

}
